package day07;

import java.util.Scanner;

public class CalTotalAvg {
   /* public static void main(String[] args) {
        double[] gress = enterData();
        double zonghe = calTotal(gress);
        System.out.println("总分为：" + zonghe);
        int a = (int) zonghe / (gress.length - 2);
        System.out.println("平均数为：" + a);
    }*/
    /*public static void main(String[] args) {
        double[] gress = enterData();
        double zonghe = calTotal(gress);
        System.out.println("总分为：" + zonghe);
        int a = (int) zonghe / (gress.length - 2);
        System.out.println("平均数为：" + a);
    }*/
    public static void main(String[] args) {
        double[] gress = enterData();
        double zonghe = calTotal(gress);
        System.out.println("总分为：" + zonghe);
        int a = (int) zonghe / (gress.length - 2);
        System.out.println("平均数为：" + a);
    }
    public static double calAvg(double[]gress){
        double zonghe =calTotal(gress);
        double avg=zonghe/(gress.length-2);
        return avg;
    }
    public static double[] enterData(){
        Scanner scan=new Scanner(System.in);
        double[] gress=new double[6];
        for(int i=0;i<gress.length;i++){
            System.out.println("请输入第"+(i+1)+"位评委的分数：");
            gress[i]=scan.nextDouble();
        }
        return gress;
    }
    public static double calTotal(double[] gress){
      /*double zonghe= gress[0]+gress[1]+gress[2]+gress[3]+gress[4]+gress[5];*/
        double zonghe=0.0;
        double max=gress[0];
        double min=gress[0];
        for(int i=0;i<gress.length;i++){
            if(gress[i]>max){
                max=gress[i];
            }
            if(gress[i]<min){
                min=gress[i];
            }
            zonghe +=gress[i];
        }
        return zonghe-max-min;
    }
    /*public static double calAvg(double[] gress) {
        double zonghe = calTotal(gress);
        double avg = zonghe / (gress.length - 2);
        return avg;
    }

    public static double[] enterData() {
        Scanner scan = new Scanner(System.in);
        double[] gress = new double[6];
        for (int i = 0; i < gress.length; i++) {
            System.out.println("请输入第" + (i + 1) + "位评委的分数：");
            gress[i] = scan.nextDouble();
        }
        return gress;
    }

    public static double calTotal(double[] gress) {
        /* double zonghe= gress[0]+gress[1]+gress[2]+gress[3]+gress[4]+gress[5];*/
        /*double zonghe = 0.0;
        double max = gress[0];
        double min = gress[0];
        for (int i = 0; i < gress.length; i++) {
            if (gress[i] > max) {
                max = gress[i];
            }
            if (gress[i] < min) {
                min = gress[i];
            }
            zonghe += gress[i];
        }
        return zonghe - max - min;
    }
    public static double calAvg(double[]gress){
        double zonghe =calTotal(gress);
        double avg=zonghe/(gress.length-2);
        return avg;
    }
    public static double[] enterData(){
        Scanner scan=new Scanner(System.in);
        double[] gress=new double[6];
        for(int i=0;i<gress.length;i++){
            System.out.println("请输入第"+(i+1)+"位评委的分数：");
            gress[i]=scan.nextDouble();
        }
        return gress;
    }
    public static double calTotal(double[] gress){
        /* double zonghe= gress[0]+gress[1]+gress[2]+gress[3]+gress[4]+gress[5];*/
       /* double zonghe=0.0;
        double max=gress[0];
        double min=gress[0];
        for(int i=0;i<gress.length;i++){
            if(gress[i]>max){
                max=gress[i];
            }
            if(gress[i]<min){
                min=gress[i];
            }
            zonghe +=gress[i];
        }
        return zonghe-max-min;*/
}

